package com.huiztech.kaoqinji.mvc;

import android.app.AlertDialog;
import android.content.DialogInterface;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;

import com.huiztech.common.mvc.HuizView;

public class KaoqinView extends HuizView {

    private AlertDialog dialog;

    public void showDialog(int dialogView, int cancelBtnId, int submitBtnId, OnClickListener listener) {
        dialog = new AlertDialog.Builder(context).create();
        dialog.show();
        
        OnClickListener onClickListener = listener;
        if (onClickListener == null) {
            onClickListener = new OnClickListener() {

                @Override
                public void onClick(View v) {
                }

            };
        }

        Window window = dialog.getWindow();
        window.setContentView(dialogView);
        window.findViewById(cancelBtnId).setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                hideDialog();
            }
        });
        window.findViewById(submitBtnId).setOnClickListener(onClickListener);

    }
    
    public void hideDialog(){
        dialog.dismiss();
    }
}
